package com.qf.controller;

import com.qf.pojo.Student;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/stu")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping
    public List<Student> findAll(){
        return studentService.findAll();
    }

    @GetMapping("/{id}")
    public Student findOne(@PathVariable("id") Integer id){
		
        List<Student> stu = studentService.findById(id);
        return stu.get(0);
    }

    @PostMapping("/update")
    public void update(@RequestBody Student stu){
        studentService.update(stu);
    }
}
